// Author: combacsa@kaist.ac.kr
// http://www.jungol.co.kr/prog/Hanal/hanalView.php?qs_code=2204

//#define COMPILE
#ifdef COMPILE

#include <fstream>
#include <stack>
using namespace std;

int n;
int data[1000];
bool answer;

void input() {
	ifstream in("input.txt");
	in >> n;
	for (int i = 0; i < n ;i++) 
		in >> data[i];
	in.close();
}

void output() {
	ofstream out("output.txt");
	if (answer) 
		out << "Yes";
	else
		out << "No";
	out.close();
}

void solve() {
	stack<int> temp;
	int curr = 1;
	int idx = 0;
	while (curr <= n) {
		if (data[idx] == curr) {
			idx++;
			curr++;
		} else if ((temp.empty() == false) && (temp.top() == data[idx])) {
			temp.pop();
			idx++;
		} else {
			temp.push(curr);
			curr++;
		}
	}
	while (!temp.empty()) {
		if (data[idx] == temp.top()) {
			temp.pop();
			idx++;
		} else
			break;
	}
	if (temp.empty())
		answer = true;
	else
		answer = false;
}

int main() {
	input();
	solve();
	output();
	return 0;
}

#endif
